﻿@using DTcms.Common;
@{
    ViewBag.Title = "URL配置管理";
    List<SelectListItem> typeList = new List<SelectListItem>(){
        new SelectListItem(){ Text="所有类型", Value=""},
        new SelectListItem(){ Text="首页", Value="index"},
        new SelectListItem(){ Text="列表页", Value="list"},
        new SelectListItem(){ Text="栏目页", Value="category"},
        new SelectListItem(){ Text="详细页", Value="detail"},
        new SelectListItem(){ Text="插件页", Value="plugin"},
        new SelectListItem(){ Text="其他页", Value="other"}
    };
}
<div class="pageheader">
    <div class="page-bar">
        <ul class="page-breadcrumb">
            <li><a href="javascript:;"><i class="iconfont icon-home1"></i> 首页</a> </li>
            <li><a href="javascript:;">系统管理</a> </li>
            <li><a href="javascript:;">URL配置</a> </li>
        </ul>
    </div>
</div>
<div class="layui-fluid">
    <div class="layui-card layui-tab">
        <div class="layui-card-body table-tool-mini">
            <div class="layui-form toolbar">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <div class="layui-btn-group">
                            <a data-type="btnAdd" class="layui-btn icon-btn layui-btn-normal layui-btn-sm" href="../settings/url_rewrite_edit?action=@DTEnums.ActionEnum.Add"><i class="iconfont icon-close1"></i><span> 新增</span></a>
                            <a data-type="btnDelete" class="layui-btn icon-btn layui-btn-normal layui-btn-sm"><i class="iconfont icon-delete"></i><span> 删除</span></a>
                        </div>
                        <div class="menu-select">
                            <select class="select" lay-filter="btnSearch" name="ddlSite" url="/webapi/siteJson" selectValue="" promtion="所有站点"><option value="">所有站点</option></select>
                            <select class="select" lay-filter="btnSearch" name="ddlChannel" url="/webapi/channelJson" selectValue="" promtion="所有频道"><option value="">所有频道</option></select>
                            @Html.DropDownList("ddlPageType", new SelectList(typeList, "Value", "Text"), new { @lay_filter = "btnSearch" })
                        </div>
                    </div>
                </div>
            </div>
            <table class="layui-table" lay-data="{page:true, id:'ltable'}" lay-filter="ltable">
                <thead>
                    <tr>
                        <th lay-data="{checkbox:true}"></th>
                        <th lay-data="{field:'name'}">调用名称</th>
                        <th lay-data="{field:'page'}">源页面名称</th>
                        <th lay-data="{field:'inherit'}">继承类名</th>
                        <th lay-data="{field:'templet'}">模板名称</th>
                        <th lay-data="{field:'channel'}">归属频道</th>
                        <th lay-data="{field:'pagesize'}">分页数量</th>
                        <th lay-data="{templet: '#barDemo'}">操作</th>
                    </tr>
                </thead>
            </table>
        </div>
    </div>
</div>
<script type="text/html" id="barDemo">
    <a href="../settings/url_rewrite_edit?action=@DTEnums.ActionEnum.Edit&name={{d.name}}" class="layui-btn layui-btn-primary layui-btn-xs">修改</a>
</script>
@section Scripts{
    <script type="text/javascript">
        layui.use(['table', 'cascadeSelect', 'cmswh'], function () {
            var table = layui.table, form = layui.form, cascadeSelect = layui.cascadeSelect, cmswh = layui.cmswh, $ = layui.jquery;
            cascadeSelect.init('ddlSite', false);
            cascadeSelect.init('ddlChannel', false);

            cmswh.dataBind('UrlRewriteList', getcond(), false);
            var active = {
                btnDelete: function () {
                    cmswh.batOperate('UrlRewriteDelete', 'name', "本操作会导致网站前台无法运作，是否继续？");
                },
                btnSearch: function () {
                    cmswh.dataBind('UrlRewriteList', getcond(), false);
                }
            };
            form.on('select(btnSearch)', function (data) {
                var type = "btnSearch";
                active[type] ? active[type].call(this) : '';
            });
            $('.layui-inline .layui-btn').on('click', function () {
                var type = $(this).data('type');
                active[type] ? active[type].call(this) : '';
            });
            /*拼接条件返回postdata*/
            function getcond() {
                var ddlsite = $("select[name=ddlsite]").val();
                var ddlchannel = $("select[name=ddlChannel]").val();
                var ddltype = $("#ddlPageType").val();
                var postdata = { channel: ddlchannel, site: ddlsite, type: ddltype };
                return postdata;
            }
        });
    </script>
}